<?php    
    # Suorita haku
    $search = API::userGetUserWeight($_POST);
?>

<table class="table table-hover">
    <thead>
        <tr>
            <th>
                Date
            </th>
            <th>
                Weight (KG)
            </th>
            <th>
                Weight (LB)
            </th>
            <th>
                Fat percentage
            </th>
            <th>
                Measurement time
            </th>
            <th>
                &nbsp;
            </th>
        </tr>
    </thead>
    
    <tbody>
        <?php
            $list = (array)arrGet($search,"list");
            foreach ($list as $row) {
                $hashid = htmlescape($row["hashid"]);
        ?>
                <tr>
                    <td>
                        <a class="a-subview-dialog"
                          data-ui-view="userweight"
                          data-ui-subview="info"
                          data-ui-title="Workouts for measurement data"
                          data-hashid="<?php echo $hashid; ?>"
                          href="#">
                            <?php echo htmlescape($row["date"]); ?>
                        </a>
                    </td>
                    <td>
                        <?php
                            if (is_numeric($row["weight_kg"])) {
                                echo $row["weight_kg"];
                            } else {
                                echo "&nbsp;";
                            }
                        ?>
                    </td>
                    <td>
                        <?php
                            if (is_numeric($row["weight_lb"])) {
                                echo $row["weight_lb"];
                            } else {
                                echo "&nbsp;";
                            }
                        ?>
                    </td>
                    <td>
                        <?php
                            if (is_numeric($row["fatpercent"])) {
                                echo $row["fatpercent"];
                            } else {
                                echo "&nbsp;";
                            }
                        ?>
                    </td>
                    <td>
                        <?php
                            echo htmlescape(
                                getMeasurementTimeDesc($row["measurement_time"])
                            );
                        ?>
                    </td>
                    <td>
                        <?php
                            FT::$autoescape = false;
                            FT::button("<span class=\"glyphicon glyphicon-trash\" aria-hidden=\"true\"></span>",array(
                                "class"         => "userweight-button-delete-weight btn btn-default btn-xs",
                                "data-hashid"   => $hashid,
                                "title"         => "Delete weight data"
                            ));
                            FT::$autoescape = true;
                        ?>
                    </td>
                </tr>
        <?php
            }
        ?>
    </tbody>
</table>